package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.WxBannerConfig;
import com.ruoyi.business.service.IWxBannerConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广告图配置Controller
 * 
 * @author asher
 * @date 2021-11-12
 */
@RestController
@RequestMapping("/business/banner_config")
public class WxBannerConfigController extends BaseController
{
    @Autowired
    private IWxBannerConfigService wxBannerConfigService;

    /**
     * 查询广告图配置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WxBannerConfig wxBannerConfig)
    {
        startPage();
        List<WxBannerConfig> list = wxBannerConfigService.selectWxBannerConfigList(wxBannerConfig);
        return getDataTable(list);
    }

    /**
     * 导出广告图配置列表
     */
    @PreAuthorize("@ss.hasPermi('business:banner_config:export')")
    @Log(title = "广告图配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WxBannerConfig wxBannerConfig)
    {
        List<WxBannerConfig> list = wxBannerConfigService.selectWxBannerConfigList(wxBannerConfig);
        ExcelUtil<WxBannerConfig> util = new ExcelUtil<WxBannerConfig>(WxBannerConfig.class);
        return util.exportExcel(list, "广告图配置数据");
    }

    /**
     * 获取广告图配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:banner_config:query')")
    @GetMapping(value = "/{bannerId}")
    public AjaxResult getInfo(@PathVariable("bannerId") Long bannerId)
    {
        return AjaxResult.success(wxBannerConfigService.selectWxBannerConfigByBannerId(bannerId));
    }

    /**
     * 新增广告图配置
     */
    @PreAuthorize("@ss.hasPermi('business:banner_config:add')")
    @Log(title = "广告图配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxBannerConfig wxBannerConfig)
    {
        return toAjax(wxBannerConfigService.insertWxBannerConfig(wxBannerConfig));
    }

    /**
     * 修改广告图配置
     */
    @PreAuthorize("@ss.hasPermi('business:banner_config:edit')")
    @Log(title = "广告图配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxBannerConfig wxBannerConfig)
    {
        return toAjax(wxBannerConfigService.updateWxBannerConfig(wxBannerConfig));
    }

    /**
     * 删除广告图配置
     */
    @PreAuthorize("@ss.hasPermi('business:banner_config:remove')")
    @Log(title = "广告图配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bannerIds}")
    public AjaxResult remove(@PathVariable Long[] bannerIds)
    {
        return toAjax(wxBannerConfigService.deleteWxBannerConfigByBannerIds(bannerIds));
    }
}
